import { createStore } from 'vuex';
import createPersistedState from 'vuex-persistedstate';//持久化数据插件

export default createStore({
  state: {
    isGetRouter: false,
    isCollapse: false,
    userInfo: {}
  },
  getters: {
  },
  mutations: {
    changeGetRouter(state, value) {
      state.isGetRouter = value
    },
    // 侧边栏折叠
    changeCollapse(state) {
      state.isCollapse = !state.isCollapse
    },
    getUserInfo(state, val) {
      state.userInfo = {
        ...state.userInfo, ...val
      }
    },
    clearUerInfo(state, val) {
      state.userInfo = {}
    },
  },
  actions: {
  },
  modules: {
  },
  // 默认存储到本地local Storage里
  plugins: [createPersistedState({
    paths: ['isCollapse', 'userInfo']//配置持久化的数据
  })]
})
